package com.itany.corejava.code14_lambda;

import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;

/**
 * @author Miss Chen
 * @version 1.0
 * @date 2024年08月09日10:00
 */
public class Test03_供给型接口 {

    public static void main(String[] args) {
        // List<String> list=testSupplier(new Supplier<List<String>>() {
        //     @Override
        //     public List<String> get() {
        //         return Arrays.asList("aa","bb","cc","dd");
        //     }
        // });
        // System.out.println(list);

        //Lambda表示式
        List<String> list=testSupplier(()->Arrays.asList("aa","bb","cc","dd"));
        System.out.println(list);
    }

    // 供给型接口Supplier<T>  无参   有返回值T   T get()
    public static List<String> testSupplier(Supplier<List<String>> supplier){
        return supplier.get();
    }
}
